<template>
  <div class="innerWrapper">
    <ul class="apiInfoWrapper">
      <li>接口地址：{{ serviceInfo.api?serviceInfo.api.url:''}}</li>
      <li>返回类型：{{ serviceInfo.api?serviceInfo.api.resFormat:'' }}</li>
      <li>请求方式：{{ serviceInfo.api?serviceInfo.api.requestWay:'' }}</li>
      <li>
        <el-tooltip placement="bottom-start" popper-class="popperWidth" :disabled="serviceInfo.api.requestExample.length < 100">
          <div slot="content">{{ serviceInfo.api.requestExample ? serviceInfo.api.requestExample :'' }}</div>
          <div class="req-sample">请求示例: {{ serviceInfo.api.requestExample ? serviceInfo.api.requestExample :'' }}</div>
        </el-tooltip>
      </li>
      <li>
        <el-tooltip placement="bottom-start" popper-class="popperWidth" :disabled="serviceInfo.api.responseExample.length < 100">
          <div slot="content">{{ serviceInfo.api?serviceInfo.api.responseExample:'' }}</div>
          <div class="req-sample">返回示例: {{ serviceInfo.api?serviceInfo.api.responseExample:'' }}</div>
        </el-tooltip>
      </li>
    </ul>
    <div class="appDetailWrapper">
      <p>微服务简介</p>
      <div class="content">{{serviceInfo.description}}</div>
    </div>
    <div class="appDetailWrapper">
      <p>参数详情</p>
      <div class="content">
        <p class="paramTypeTitle">请求参数详情：</p>
        <div class="paramFieldTitle">
          <div class="param1">名称</div>
          <div class="param2">必填</div>
          <div class="param3">类型</div>
          <div class="param4">说明</div>
        </div>
        <div v-for="(item, index) of serviceInfo.reqParam" :key="index" class="paramWrapper">
          <div class="oneLine">
            <div class="param param1">{{ item.name }}</div>
            <div class="param param2">{{ item.isRequired ? '是' : '否' }}</div>
            <div class="param param3">{{ item.type }}</div>
            <div class="param param4">{{ item.comment }}</div>
          </div>
        </div>
        <p class="paramTypeTitle">返回参数详情：</p>
        <div class="paramFieldTitle">
          <div class="param1">名称</div>
          <div class="param2">类型</div>
          <div class="param4">说明</div>
        </div>
        <div
          v-for="(item, index) of serviceInfo.resParam"
          :key="index + item.name"
          class="paramWrapper"
        >
          <div class="oneLine">
            <div class="param param1">{{ item.name }}</div>
            <div class="param param2">{{ item.type }}</div>
            <div class="param param4">{{ item.comment }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {}
  },
  computed: {},
  props: {
    serviceInfo: {
      type: Object,
      default: () => {
        return { api: { requestExample: '' } }
      }
    }
  },
  created() {}
}
</script>
<style lang="scss" scoped>
.innerWrapper {
  .apiInfoWrapper {
    li {
      list-style: none;
      line-height: 40px;
      color: #6c6c6c;
    }
    .req-sample {
      word-break:break-word;
      text-overflow: ellipsis;
      overflow: hidden;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      line-clamp: 2;
      -webkit-box-orient: vertical;
    }
  }
  .appDetailWrapper {
    margin-top: 65px;
    margin-bottom: 40px;
    font-size: 24px;
    color: rgba(56, 56, 56, 1);
    line-height: 33px;
    .content {
      font-size: 16px;
      min-height: 150px;
      padding: 10px;
      box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.1);
      border-radius: 10px;
      border: 1px solid rgba(0, 0, 0, 0.1);
    }
    .paramTypeTitle {
      padding-left: 24px;
      color: rgba(56, 56, 56, 1);
      font-size: 18px;
    }
    .paramFieldTitle {
      border: solid 1px rgba(151, 151, 151, 0.3);
      border-left: none;
      border-right: none;
      display: flex;
      width: calc(100% - 48px);
      margin: 0 auto;
      justify-content: space-between;
      align-items: center;
      font-size: 16px;
      color: rgba(77, 98, 115, 1);
      div {
        padding: 10px 24px;
      }
      .param1 {
        flex: 1;
      }
      .param2 {
        flex: 1;
      }
      .param3 {
        flex: 1;
      }
      .param4 {
        flex: 1;
      }
    }
    .paramWrapper {
      .oneLine {
        display: flex;
        width: calc(100% - 48px);
        margin: 0 auto;
        justify-content: space-between;
        align-items: center;
        font-size: 14px;
        color: rgba(109, 114, 120, 1);
        color: #6d7278;
        line-height: 30px;
        .param {
          padding: 10px 24px;
        }
        .param1 {
          flex: 1;
        }
        .param2 {
          flex: 1;
        }
        .param3 {
          flex: 1;
        }
        .param4 {
          flex: 1;
        }
      }
    }
  }
}
</style>
